import { createWebHistory, createRouter } from 'vue-router';
import { defaultRoutes } from './routes';
import { useRouterGuard } from './guard';

const router = createRouter({
  history: createWebHistory(),
  routes: defaultRoutes
});

/**
 * 初始化路由
 *
 * @param app
 * @returns void
 */
export async function setupRouter(app) {
  app.use(router);
  useRouterGuard(router);
  await router.isReady();
}

export default router;
